<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>批次信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">	
	    $(document).ready(function(){
	    	finishVaccineIdCompany();
	    	$(document).on("click","#btnReset",function(){
	    		$("#vaccineId").val("").select2();
				$("#companyName").val("").select2();
				$("#batchno").val("");
				$("#beginVaccExpDate").val("");
				$("#endVaccExpDate").val("");
			});
	    })
	    function down(){
			top.$.jBox.confirm("确认要导出注射器批次数据吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$("#searchForm").attr("action","${ctx}/vaccinate/bsVaccineBatchno/exportSyringe");
					$("#searchForm").submit();
				}
				$("#searchForm").attr("action","${ctx}/vaccinate/bsVaccineBatchno/manageBatchno");
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
	    /* function reset(){
			$("#vaccineId").val("").select2();
			$("#companyName").val("").select2();
			$("#batchno").val("");
			$("#beginVaccExpDate").val("");
			$("#endVaccExpDate").val("");
		} */
		/* 选择注射器名称加载生产厂家 */
		$(document).on("change","#vaccineId",function(){
			var str=$("#vaccineId").val();
			var com=$("#companyName").val();
			if(str=='请选择'){
				$("#companyName").find("option").remove(); 
				$("#companyName").select2();
				return ;
			}
			var html = '<option value="">--请选择--</option>';
			$("#companyName").find("option").remove(); 
			$("#companyName").select2();
			$.ajax({
				url:"${ctx}/vaccinate/bsVaccineBatchno/getCompanyVaccId",
				data:{"id":$(this).val()},
				success: function(data){ 
					data = data=$.parseJSON(data);
					for(var i=0;i<data.length;i++){
						html += "<option value="+data[i].companyCode+">" + data[i].companyName + "</option>";
					}
					$("#companyName").html(html);
					$("#companyName").select2();
				}
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
        
		var bsVaccineBatchno = JSON.parse('${fns:toJson(bsVaccineBatchno)}');
		function finishVaccineIdCompany(){
			if(bsVaccineBatchno && bsVaccineBatchno["vaccineId"]){
			   $("#vaccineId").val(bsVaccineBatchno.vaccineId);
			   $("#vaccineId").select2();
			   if(bsVaccineBatchno["companyName"]){
				   $.ajax({
						url:ctx + "/vaccinate/bsVaccineBatchno/getCompanyVaccId",
						data:{"id":bsVaccineBatchno.vaccineId},
						success: function(data){
							data = data=$.parseJSON(data);
							var html ="<option value=''>--请选择--</option>";
							$.each(data,function(i,t){
								html += "<option value=" + t.companyCode + ">" + t.companyName + "</option>"
							});
							$("select").each(function(){
								if($(this).hasClass("selectCompany")){
									$(this).html(html);
									$(this).select2();
									finishSelectCompany();
								 }				
							});
						}
					});  
			   }else{
				   $.ajax({
						url:ctx + "/vaccinate/bsVaccineBatchno/getCompanyVaccId",
						data:{"id":bsVaccineBatchno.vaccineId},
						success: function(data){
							data = data=$.parseJSON(data);
							var html ="<option value=''>--请选择--</option>";
							$.each(data,function(i,t){
								html += "<option value=" + t.companyCode + ">" + t.companyName + "</option>"
							});
							$("select").each(function(){
								if($(this).hasClass("selectCompany")){
									$(this).html(html);
									$(this).select2();
								 }				
							});
						}
					});
			    }
			}
		}
		
		function finishSelectCompany(){
			$("#companyName").val(bsVaccineBatchno.companyName);
			$("#companyName").select2();
		}
	
	</script>

<style type="text/css">
	.minWidth {
		min-width: 177px;
	}	
	#td {
	    min-width: 90px;
	}
	#contentTable td ,#contentTable th{
		text-align: center;
		padding:1px 16px;
	}
</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<%-- <li class="active"><a href="${ctx}/vaccinate/bsVaccineBatchno/manageBatchno?batchType=2">注射器批次信息管理</a></li> --%>
		<li class="active"><a href="#">注射器批次信息管理</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="bsVaccineBatchno" action="${ctx}/vaccinate/bsVaccineBatchno/manageBatchno" method="post" class="breadcrumb form-search">
		<input id="batchType" name="batchType" type="hidden" value="${bsVaccineBatchno.batchType}"/>
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		 <table class="table table-bordered">
			<tr>
				<td><span>注射器名称</span></td>
				<td>
					<form:select path="vaccineId" id="vaccineId" class="span2 minWidth">
						<form:option value="" label="--请选择--"/>
						<c:forEach items="${fns:getDictList('batch_syringe_type')}" var="dict">
							<option value="${dict.value}">${dict.label}</option>
						</c:forEach>
					</form:select>     
				</td>
				<td><span>注射器生产厂家</span></td>
				<td>
					<form:select path="companyName" id="companyName"  class="span2 minWidth selectCompany">
						<form:option value="" label="--请选择--"/>
					</form:select>
				</td> 
				<td id="td"><span>批号</span></td>
				<td><form:input path="batchno" class="input-medium minWidth"></form:input></td>
			</tr>
			
			<tr>
				<td class="clo-ml-m4"><span>有效起始日期</span></td>
				<td>
					<input id="beginVaccExpDate" name="beginVaccExpDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${bsVaccineBatchno.beginVaccExpDate}" pattern="yyyy-MM-dd"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
				</td>
				<td class="clo-ml-m4"><span>有效截止日期</span></td>
				<td colspan="3">
					<input id="endVaccExpDate" name="endVaccExpDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${bsVaccineBatchno.endVaccExpDate}" pattern="yyyy-MM-dd"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
				</td>
			</tr>
		</table> 
		<div>
			<button id="btnSubmit" class="btn btn-primary" type="submit" >查询</button>
			<button id="btnReset" class="btn btn-primary" type="button" onclick = "rese()">重置</button>
			<button id="btnDown" class="btn btn-primary" type="button" onclick="down()">导出</button>
			<%-- <a href="${ctx}/vaccinate/bsVaccineInfo/form?batchType=${bsVaccineBatchno.batchType}" class="btn btn-primary">添加</a> --%>
			<a href="${ctx}/vaccinate/bsVaccineBatchno/addForm?batchType=${bsVaccineBatchno.batchType}" class="btn btn-primary">添加</a>
		</div>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th width="60px">操作</th>
				<th>注射器类型</th>
				<th>生产企业</th>
				<th>批号</th>
				<th>有效日期</th>
				<th>规格</th>
				<th>录入单位</th>
				<th>修改时间</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="bsVaccineBatchno"  begin="0"  varStatus="status">
			<tr>
				<td><%-- <a href="${ctx}/vaccinate/bsVaccineBatchno/form?id=${bsVaccineBatchno.id}">修改</a> --%>
					<a href="${ctx}/vaccinate/bsVaccineBatchno/editForm?id=${bsVaccineBatchno.id}">修改</a> </td>
				<td>${fns:getDictLabel(bsVaccineBatchno.vaccineId, 'batch_syringe_type', '')}</td>
				<td>${bsVaccineBatchno.companyName}</td>
				<td>${bsVaccineBatchno.batchno}</td>
				<td><fmt:formatDate value="${bsVaccineBatchno.outBoundDate}" pattern="yyyy-MM-dd"/></td>
				<td>${bsVaccineBatchno.spec}</td>	
				<td>${bsVaccineBatchno.createOrgName }</td>
				<td><fmt:formatDate value="${bsVaccineBatchno.updateDate}" pattern="yyyy-MM-dd"/> </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>